import static java.lang.Thread.sleep;

public class Demo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Runnable() {
            public void run() {
                while (true) {
                    System.out.println(Thread.currentThread().getName());
                    try {
                        sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }, "thread");
        thread.start();
        while (true) {
            System.out.println(Thread.currentThread().getName());
            sleep(1000);
        }
    }
}
